package pqt;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Toolkit;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Fidelidad extends JDialog {

	private final JPanel contentPanel = new JPanel();
	int veces = 0;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			Fidelidad dialog = new Fidelidad();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Fidelidad() {
		setTitle("Fidelidad");
		setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setIconImage(Toolkit.getDefaultToolkit().getImage(Fidelidad.class.getResource("/img/icono.png")));
		setBounds(100, 100, 814, 532);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBackground(new Color(204, 204, 204));
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JLabel lblColoquePesaDe = new JLabel("<html><p align='center'>Coloque pesa de XXXX gramos en el centro de la balanza y oprima OK una vez que el equipo este estable</p></html>");
			lblColoquePesaDe.setFont(new Font("Tahoma", Font.PLAIN, 30));
			lblColoquePesaDe.setBounds(10, 11, 778, 182);
			lblColoquePesaDe.setFocusable(false);
			contentPanel.add(lblColoquePesaDe);
		}
		
		final JButton btnOk = new JButton("");
		btnOk.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(veces == 0){
				TablaExcentricidad tabla = new TablaExcentricidad();
				tabla.setLocationRelativeTo(null);
				tabla.setModal(true);
				tabla.setVisible(true);
				veces++;
				}
				else
				{
				dispose();
				}
			}
		});
		btnOk.setFocusable(true);
		btnOk.setContentAreaFilled(false);
		btnOk.setBorderPainted(false);
		btnOk.setBorder(null);
		btnOk.setBounds(279, 318, 265, 87);
		btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
		btnOk.setPressedIcon(new ImageIcon(testBoton.class.getResource("/img/OkBlancoGrande.png")));
		btnOk.addMouseListener(new MouseAdapter() {
			
			public void mouseEntered(MouseEvent arg0) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkVerdeGrande.png")));
				getRootPane().setDefaultButton(btnOk);
				
			}
			@Override
			public void mouseExited(MouseEvent e) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		btnOk.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent arg0) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkVerdeGrande.png")));
				getRootPane().setDefaultButton(btnOk);
			}
			@Override
			public void focusLost(FocusEvent e) {
				btnOk.setIcon(new ImageIcon(testBoton.class.getResource("/img/OkAzulGrande.png")));
				getRootPane().setDefaultButton(null);
			}
		});
		contentPanel.add(btnOk);
	}

}
